class FindSumPairs {
public:
    FindSumPairs(vector<int>& nums1, vector<int>& nums2) 
        :_nums1(nums1),
        _nums2(nums2)
    {
        for(int num:nums2) cnt[num]++;
    }

    void add(int index, int val) {
        cnt[_nums2[index]]--;
        _nums2[index] += val;
        cnt[_nums2[index]]++;
    }
    
    int count(int tot) {
        int ans = 0;
        for(int num : _nums1)
        {
            int gap = tot - num;
            if(cnt.count(gap)) ans += cnt[gap];
        }
        return ans;
    }
private:
    vector<int> _nums1,_nums2;
    unordered_map<int,int> cnt;
};

/**
 * Your FindSumPairs object will be instantiated and called as such:
 * FindSumPairs* obj = new FindSumPairs(nums1, nums2);
 * obj->add(index,val);
 * int param_2 = obj->count(tot);
 */
